package com.jvxb.manage.livable.service.impl;

import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jvxb.manage.livable.service.SysDictService;
import com.jvxb.manage.livable.mapper.SysDictMapper;
import com.jvxb.manage.livable.entity.SysDict;

import java.util.List;

/**
 * @author jvxb
 * @since 2022-01-13
 */
@Service
public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> implements SysDictService {

    @Override
    public List<SysDict> getSysDictByGroup(String groupName) {
        return baseMapper.getSysDictByGroup(groupName);
    }

    @Override
    public String getUniValueByGroupAndKey(String groupName, String dkey) {
        return baseMapper.getUniValueByGroupAndKey(groupName, dkey);
    }

    @Override
    public String getUniValueByGroupAndKey(String groupName, String dkey, Object defaultValue) {
        String value = baseMapper.getUniValueByGroupAndKey(groupName, dkey);
        return value == null ? (defaultValue == null ? null : defaultValue.toString()) : value;
    }

    @Override
    public void updateConfigValue(String groupName, String dkey, String dvalue) {
        baseMapper.updateConfigValue(groupName, dkey, dvalue);
    }

    @Override
    public void insertConfigValue(String groupName, String dkey, String dvalue) {
        baseMapper.insertConfigValue(groupName, dkey, dvalue);
    }
}
